<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
<title>蒋路的报警页面</title>
</head>
<body>
	<script type="text/javascript"> 
	
	$.extend($.fn.validatebox.defaults.rules, {
		Chackpho: {
	        validator: function(value){
	        	  var myreg =/^1[34578]\d{9}$/;
	        	  if( myreg.test(value)){
	        		  return true;
	        	  }else{
	        		  return false;
	        	  }
	        	   
	        },
	        message: '电话号码有误！！'
	    }
	});
	
	
		$(function(){
			$("#addalarm").linkbutton({
				onClick:function(){
					$('#alarmwin').window({'title': "报警登记"});
					$("#alarmwin").window('open');
					$("#alarmstuff").form("clear");
					$("#arAidDate").textbox("setValue",needDate );
					$("#arArriveDate").textbox("setValue",needDate );
					$("#arReturnAdate").textbox("setValue",needDate );
					$("#arRetureHdate").textbox("setValue",needDate );			
				}
			});
			$("#alarm-save").linkbutton({  
				onClick : function() {
					
					alert("来了");
					alert($("arRetureHdate").datetimebox("getValue"));
					$('#alarmstuff').form('submit', {
						onSubmit : function() {
						},				
						success : function(data) {
							var json = eval("("+data+")");
							$.messager.alert("提示", json.reason);
							//关闭窗口
							$("#alarmwin").window('close');
							//重新加载数据
							$("#alarmtab").datagrid("reload");
							$(this).form("clear");
							
						}
					});
				}
			});
		
			
			$("#alarmdeltool").linkbutton({onClick: function(){
				var rows = $("#alarmtab").datagrid("getSelections");
				  if(rows.length>0){
					 $.messager.confirm("提示", "确定要删除吗？", function(v){
						if(v){
							    //获取所有选中的编号
							    var rows = $("#alarmtab").datagrid("getSelections");	
								//将编号保存到数组中
								var arr = [];
								for(var i = 0; i < rows.length; i ++){
									arr.push(rows[i].arId);
								}
								//用form提交
								$('<form>').form('submit', {
								    url:'delalarm',
								    onSubmit: function(param){
								    	param.list=arr;
								    },
								    success:function(data){
								    	var json = eval("(" + data + ")");
										$.messager.alert("提示", json.reason);
										$("#alarmtab").datagrid("reload");
								    }});
						  }
					});
					
				  }
			      else{$.messager.alert("提示", "请选择需要删除的记录！"); }
			}});
	
			
			$("#alarmcancel").linkbutton({
				onClick : function() {
					$('#alarmstuff').form("clear");
					$("#alarmwin ").window("close");
				}
			});
			$("#alarmref").linkbutton({
				onClick:function(){
					$("#alarmtab").datagrid({
						 url: 'toalarmpage'
					});
				}
			});
			$('#alarmsearch').searchbox({
			    searcher:function(value,name){
			    	 if(name=="话务员"){
			    		$("#alarmtab").datagrid({
				    		url:'findbyhwy',
				    		queryParams: {
				    			price: value
				    		}
				    	});
			    	}else if(name=="报警人名"){
			    		$("#alarmtab").datagrid({
				    		url:'findbybjrm',
				    		queryParams: {
				    			price: value
				    		}
				    	});
			    	}	    	
			    	
			    }
			});
		});
	</script>
	
	  <table id="alarmtab" class="easyui-datagrid"
			data-options="
				fitColumns:true,
				fit:true,
				rownumbers: true,
			    url: 'toalarmpage',
				border:false ,
				pagination:true,
				toolbar: '#alarmjl_btn',
				pageSize: 10,
				pageList:[10,20,30,40]
			">
			<thead>            
				<tr> 
					<th class="ident" data-options="field:'arId',checkbox:true">报警编号</th>
					<th class="ident" data-options="field:'arAidDate',width:10,formatter:function(value){
                          var unixTimestamp = new Date(value);  
                          return unixTimestamp.toLocaleDateString();}">急救日期
                    </th> 
                    <th class="ident" data-options="field:'arArriveDate',width:10,formatter:function(value){
                          var unixTimestamp = new Date(value);  
                          return unixTimestamp.toLocaleString();}">到达时间
                    </th> 
                    <th class="ident" data-options="field:'arRetureHdate',width:10,formatter:function(value){
                          var unixTimestamp = new Date(value);  
                          return unixTimestamp.toLocaleString();}">到院时间
                    </th> 
                    <th class="ident" data-options="field:'arReturnAdate',width:10,formatter:function(value){
                          var unixTimestamp = new Date(value);  
                          return unixTimestamp.toLocaleString();}">施救时间
                    </th>  
					<th class="ident" data-options="field:'arOperator',width:10">话务员</th>
					<th class="ident" data-options="field:'arPerson',width:15,editor:'textbox'">报警人姓名</th>
					<th class="ident" data-options="field:'arTelephone',width:10,">报警人电话</th>
				</tr>
			</thead>
		</table>
	
	<div id="alarmjl_btn">
		<a id="addalarm" class="easyui-linkbutton"
			data-options="iconCls:'icon-add',plain:true">添加记录</a> 
		<a id="alarmdeltool"
			class="easyui-linkbutton"
			data-options="iconCls:'icon-remove',plain:true">删除记录</a>
		<a id="alarmref"
			class="easyui-linkbutton"
			data-options="iconCls:'icon-reload',plain:true">显示全部记录</a>
		<input id="alarmsearch" class="easyui-searchbox" 
			data-options="menu:'#alarmee',width:220,prompt:'请输入。。。。'">
	</div>
	<div id="alarmee" style=" width:90px">
		<div date-options="name:'name'">话务员</div>
		<div date-options="name:'name'">报警人名</div>
	</div>
	<div>
		<div id="alarmwin" class="easyui-window"
			style="padding: 10px;line-height: 150%;"
			data-options="
		     width: 470,
		     height:233,
		     closed: true,
		     title:'学生信息操作'
			">		
				<form id="alarmstuff" action="addalarm" method="post">
					<table>
						<tr>
							<td>
								<div class="item">
									<input id="arPerson"  name="arPerson" required="required" class="easyui-textbox" data-options="label: '报警人姓名:', width: 200">
								</div>
							</td>
							<td>								
								<div class="item">
									<input id="arArriveDate"   name="arArriveDate" class="easyui-textbox" data-options="label: '到达时间 :', width: 200">
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="item">
									<input id="arAidDate"   name="arAidDate" class="easyui-textbox" data-options="label: '急救日期 :', width: 200">
								</div>
								
							</td>
							<td>
								<div class="item">
									<input id="arRetureHdate" class="easyui-datetimebox" name="arRetureHdate"data-options="label: '到院时间 :',required:true,showSeconds:false, width: 200" >
								</div>
							</td>
						</tr>
						<tr>
							<td>
							    <div class="item">
									<input id="arTelephone"  required="required" name="arTelephone" type="text" class="easyui-textbox"  data-options="label: '报警人电话:', width: 200, validType: ['Chackpho']">
								</div>
							</td>
							<td>						
								 
								<div class="item">
									<input id="arReturnAdate"   name="arReturnAdate" class="easyui-textbox" data-options="label: '施救时间 :', width: 200">
								</div>
							</td>
						</tr>
						<tr>
							<td>
								 <div class="item">
									<input id="arOperator"  name="arOperator" type="text" class="easyui-textbox"  data-options="label: '话务员:', width: 200">
								</div>							
							</td>
							<td>					
							</td>
						</tr>
						<tr>
							<td>
								<div>
									<a id="alarm-save" class="easyui-linkbutton">确定</a>
								</div>
							</td>
							<td>
								<div>
									<a id="alarmcancel" class="easyui-linkbutton">取消</a>
								</div>
							</td>
						</tr>
					</table>	
				</form>
			
		</div>
	</div>
</body>
</html>